import java.util.Scanner;

public class Test1 {
        public int search(int[] nums, int target) {
            int left = 0,right = nums.length-1 ;
            while(left <= right){
                int mid = left + (right - left) / 2;
                if(nums[mid] < target) left = mid + 1;
                else if(nums[mid] > target) right = mid - 1;
                else return mid;
            }
            return -1;
        }

    public static void main1(String[] args) {
            Scanner in = new Scanner(System.in);
       Test1 test1 = new Test1();
       //1，读入数据
       int[] nums = new int[5];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = in.nextInt();
        }
        int target = 5;
        test1.search(nums,target);



    }
    class Solution {
        public int[] searchRange(int[] nums, int target) {
            int[] ret = new int[2];
            ret[0] = ret[1] = -1;
            //处理边界条件
            if(nums.length == 0)return ret;
            //1.先找区间左端点
            int left = 0,right = nums.length - 1;
            while(left < right){
                int mid = left + (right - left)/2;
                if(nums[mid] <target )left = mid+1;
                else right = mid;
            }
            //判断是否等于要找的数据
            if(nums[left] != target) return ret;
            else ret[0] = right;
            //2.找区间的右端点
            left = 0;right = nums.length - 1;
            while(left < right){
                int mid = left + (right - left + 1)/2;
                if(nums[mid] <= target) left = mid;
                else right = mid- 1;
            }
            ret[1] = left;
            return ret;
        }
    }

    public static void main2(String[] args) {

    }


    // 注意类名必须为 Main, 不要有任何 package xxx 信息
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            //读入数据
            int n = in.nextInt(), q = in.nextInt();
            int [] arr = new int [n + 1];
            for(int i = 1;i<= n ;i++) arr[i] = in.nextInt();
            //2.预处理一个前缀和数组
            long [] dp = new long[n +1];//防止溢出（数据过大）
            for(int i  = 1;i<=n;i++)dp[i] =dp[i - 1] + arr[i];
            //3.使用前缀和数组
            while(q > 0){
                int l = in.nextInt() , r  = in.nextInt();
                System.out.println(dp[r] - dp[l - 1]);
                q--;
            }
        }
}

